<!--
 * @Author: zhangweinan
 * @Date: 2023-02-14 16:02:20
 * @LastEditors: zhangweinan
 * @LastEditTime: 2023-02-15 13:30:08
 * @Description: file content
 * @FilePath: \front-end-of-task-center\src\components\bpmnProcessDesigner\package\penal\subprocess\ElementSubprocessConfig.vue
-->
<template>
  <div class="panel-tab__content">
    <div class="element-property input-property">
      <div class="element-property__label">流程标识：</div>
      <div class="element-property__value">
        <el-select
          v-model="value"
          placeholder="请选择"
          @change="updateDocumentation"
        >
          <el-option
            v-for="item in optionData"
            :key="item.key"
            :label="item.name"
            :value="item.key"
          >
            {{ item.key }}：{{ item.name }}
          </el-option>
        </el-select>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "ElementSubprocessConfig",
  props: {
    id: String,
    optionData: Array,
  },
  data() {
    return {
      value: "",
    };
  },
  watch: {
    id: {
      immediate: true,
      handler(val) {
        val && val.length && this.$nextTick(() => this.resetFormList());
      },
    },
  },
  methods: {
    //初始化配置
    resetFormList() {
      let { calledElement } = window.bpmnInstances.bpmnElement.businessObject;
      this.value = calledElement;
    },
    updateDocumentation() {
      this.bpmnELement = window.bpmnInstances.bpmnElement;
      window.bpmnInstances.modeling.updateProperties(this.bpmnELement, {
        calledElement: this.value,
      });
      window.bpmnInstances.modeling.updateProperties(this.bpmnELement, {
        calledElementType: "key",
      });
      window.bpmnInstances.modeling.updateProperties(this.bpmnELement, {
        fallbackToDefaultTenant: "false",
      });
      window.bpmnInstances.modeling.updateProperties(this.bpmnELement, {
        inheritVariables: "true",
      });
    },
  },
  beforeDestroy() {
    this.bpmnElement = null;
  },
};
</script>
